package com.pengjunlee.hive.service;

import java.util.Set;

import org.springframework.stereotype.Service;

import redis.clients.jedis.Jedis;


@Service
public class TestService {
	
	public static void main(String[] args) {
		 new TestService().redisDB();
	}
	
	public void redisDB(){
       String host  = "127.0.0.1";
       int port = 6379;
       Jedis jedis = null;
       
       try {
       	
           jedis = new Jedis(host,port);
           jedis.auth("xz85742629");
         
           jedis.select(1);
           jedis.set("name","hello world!");
           
           
//           String name = jedis.get("name");
//           System.out.println("name = " + name);
           
           
           // jedis.flushDB();
           
           
//           String name2 = jedis.get("name");
//           System.out.println("name2 = " + name2);
           
           
       }catch (Exception e){
           e.printStackTrace();
       }finally {
           if (null != jedis){
               try {
                   jedis.close();
               }catch (Exception e){
                   System.out.println("redis连接关闭失败");
                   e.printStackTrace();
               }
           }
       }
   }
	
}